# 导包
import os
from time import sleep
from selenium import webdriver
from selenium.webdriver.support.ui import Select
from selenium.webdriver.common.by import By

# 创建浏览器对象并导入浏览器
driver = webdriver.Chrome()
driver.maximize_window()
file_path = os.path.abspath("../练习页面/注册A.html")
driver.get(file_path)

# 元素定位
# 通过ID属性定位账号
driver.find_element(By.ID, "userA").send_keys("18381702236")
sleep(1)

# 通过name的属性值定位
driver.find_element(By.NAME, "passwordA").send_keys("zyy6282987")
sleep(1)

# 通过class的属性值定位
driver.find_element(By.CLASS_NAME, "telA").send_keys("18381702236")
sleep(1)

# 通过xpath的属性值定位
driver.find_element(By.XPATH, "//*[@id='emailA']").send_keys("18381702236@163.com")
sleep(1)

driver.find_element(By.XPATH, '//button').click()
sleep(1)

driver.find_element(By.PARTIAL_LINK_TEXT, "访问").click()
sleep(1)

driver.find_element(By.ID, "AAA").click()
sleep(1)

driver.find_element(By.TAG_NAME, "我是a标签A").click()
sleep(1)

driver.find_element(By.CSS_SELECTOR, 'a[href*="www.taobao.com"]').click()
sleep(1)

# 关闭浏览器驱动
driver.quit()
